#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

typedef pair<double, double> PDD;

const int N = 1e5 + 10;
const double fps = 1e-7;

struct Car{
    double u, v0;
    double a;
    double l, r;
    // start speed a
    // overspeed : l ~ r
}e[N];

PDD a[N];
int n, m;
double L, V;
double p[N];

bool st[N];
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    int T; cin >> T;
    while(T -- )
    {
        cin >> n >> m >> L >> V; V *= V;
        for(int i = 1; i <= n; i ++ )
        {
            cin >> e[i].u >> e[i].v0 >> e[i].a;
            if(e[i].a < 0)
            {
                if(e[i].v0 * e[i].v0 > V)
                {
                    e[i].l = e[i].u;
                    e[i].r = e[i].u + (V - e[i].v0 * e[i].v0) / (double)(e[i].a * 2.0) - fps;
                }
                else e[i].l = e[i].r = 1e7;
            }
            else if(e[i].a == 0)
            {
                if(e[i].v0 * e[i].v0 > V) e[i].l = e[i].u, e[i].r = L;
                else e[i].l = 1e7, e[i].r = 1e7;
            }
            else
            {
                if(e[i].v0 * e[i].v0 > V) e[i].l = e[i].u, e[i].r = L;
                else if(e[i].v0 * e[i].v0 + (double)(2.0 * e[i].a * (L - e[i].u)) < V) e[i].l = e[i].r = 1e7;
                else
                {
                    if(e[i].v0 * e[i].v0 == V)
                        e[i].l = e[i].u + fps, e[i].r = L;
                    else e[i].l = e[i].u + (V - e[i].v0 * e[i].v0) / (double)(e[i].a * 2.0) + fps, e[i].r = L;
                }
            }
            a[i].first = e[i].r, a[i].second = e[i].l;
        }
        for(int i = 1; i <= m; i ++ ) cin >> p[i];
        sort(p + 1, p + m + 1);
        sort(a + 1, a + n + 1);

        // first -> r      second -> l

        int res1 = 0;
        for(int i = 1; i <= n; i ++ )
        {
            for(int j = 1; j <= m; j ++ )
            {
                if(p[j] > a[i].first) break;
                if(p[j] >= a[i].second && p[j] <= a[i].first)
                {
                    st[i] = true; res1 ++ ;
                    break;
                }
            }
        }
        cout << res1 << ' ';

        int k = 1;
        for(int i = 1; i <= n; i ++ )
            if(st[i]) a[k ++ ] = {a[i].second, a[i].first};

        // for(int i = 1; i < n; i ++ ) cout << a[i].first << ' ' << a[i].second << endl;
        n = k;
        int res2 = 0; k = 0;
        p[0] = -1;
        for(int i = 1; i < n; i ++ )
        {
            if(p[k] >= a[i].first && p[k] <= a[i].second) continue;
            while(p[k + 1] <= a[i].second && k + 1 <= m) k ++ ;
            res2 ++ ;
        }
        cout << m - res2 << endl;
    }

    return 0;
}
